package com.zk.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zk.entities.SysOrganization;
import com.zk.mapper.SysOrganizationMapper;
import com.zk.service.OrgServcice;

@Service
public class OrgServiceImpl implements OrgServcice{

	@Autowired
	private SysOrganizationMapper sysOrganizationMapper;
	
	/**
	 * 新增组织机构
	 * @param sysOrganization
	 * @return
	 */
	@Override
	public void add_org(SysOrganization sysOrganization) {
			Date date = new Date();
			sysOrganization.setCreateTime(date);
			sysOrganization.setModifyTime(date);
			sysOrganizationMapper.insert(sysOrganization);
		}

	@Override
	public List<SysOrganization> get_org_list() {
		return sysOrganizationMapper.select_org_all();
	}

	@Override
	public void edit_org(SysOrganization sysOrganization) {
		Date date = new Date();
		sysOrganization.setModifyTime(date);
		int edit = sysOrganizationMapper.updateByPrimaryKeySelective(sysOrganization);
		
	}

	@Override
	public int remove_org(Integer id) {
		int result = sysOrganizationMapper.deleteByPrimaryKey(id);
		return result;
	}

	@Override
	public SysOrganization get_org_by_id(Integer id) {
		return sysOrganizationMapper.selectByPrimaryKey(id);
	}

}
